﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Ticksys_ABM_Sectores_Modificar_Sectores : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataSet ds = AccesoDatos.Consulta("SELECT * FROM Sectores WHERE idSector = '" + Request.QueryString["id"] + "'");

            BoxSector.Text = ds.Tables[0].Rows[0]["Sector"].ToString();
        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        DataSet ds = AccesoDatos.Consulta("SELECT * FROM Sectores WHERE idSector <> '" + Request.QueryString["id"] + "' AND Sector = '" + BoxSector.Text + "'");

        if (ds.Tables[0].Rows.Count != 0)
        {
            lbl_Error.Visible = true;
            return;
        }

        Sector sector = new Sector();
        sector.idSector = Request.QueryString["id"];
        sector.sector = BoxSector.Text;

        GuardarEnBD.ModificarSector(sector);
        Response.Redirect("Sectores");
    }
}